<?php
    //echo $this->Html->css(array('fullcalendar.css', 'jquery-ui-1.8.9.custom.css', 'screen.css', 'ie.css'),'stylesheet', array('media'=>'screen'));
	//echo $this->Html->script(array('jquery-1.4.4.min.js', 'jquery-ui-1.8.9.custom.min.js', 'fullcalendar.min.js', 'gcal.js'));
?>


<?php
	//pr($felist);
?>

<div class="main-content grid_7 alpha">
                        <header>
                            <ul class="action-buttons clearfix fr">
                                <li><a href="../jobs/jview" class="button button-gray no-text" title="View the Task Calendar">Task Calendar<span class="calendar"></span></a></li>
                                <li><a href="documentation/index.html" class="button button-gray no-text help" rel="#overlay">Help<span class="help"></span></a></li>
                            </ul>
                            <div class="view-switcher">
                                <h2><?php echo $filterview;?> <a href="#">&darr;</a></h2>
                                <ul>
                                <?php echo $this->Html->link('Dashboard', '/jobs/jlistview'); ?>
                                    <li><?php echo $this->Html->link('Upcoming Tasks', '/jobs/jadminlist'); ?></li>
                                    <li><?php echo $this->Html->link('10 Days Ago', '/jobs/jadminlist/10days'); ?></li>
                                    <li><?php echo $this->Html->link('1 Month Ago', '/jobs/jadminlist/1month'); ?></li>
                                </ul>
                            </div>
                        </header>
                            
                        <section>
                            <ul class="listing list-view">
                                <?php
                                //echo print_r($_SESSION);
                                //echo pr($felist);
                                $today = date("Y-m-d");
                                $previous = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d")-10, date("Y")));
                                //print_r($today);
                                $usertype = $_SESSION['Group'][0]['name'];
                                foreach($felist as $task)
                                {
                                    $fortoday = date("Y-m-d", strtotime($task['Job']['sdate']));

                                if ($fortoday == $today) {
                                echo
                                '<li class="tick" id="' . $task['Job']['id'] . '">
                                    <table style="width:100%;">
                                        <tr>
                                            <th style="width:50%; text-align:left;">
                                                <a class="calendar" href="../jobs/jadmindetail/' . $task['Job']['id'] . '">&raquo;</a>'.
                                               $this->Html->link('Today', '/jobs/jadmindetail/'. $task['Job']['id']). 
                                            '</th>
                                            <th style="width:50%; float:right;">
                                                <span class="timestamp">' . $task['Job']['sdate'] . '</span>
                                            </th>
                                        </tr>
                                        <tr>
                                            <td>
                                                ' . $task['Job']['title'] . '
                                            </td>
                                            <td style="float:right;">
                                                ' . $form->button('<span class="accept"></span>Manage Task', array('class' => 'button button-gray accept', 'onclick' => 'location.href=\'' . $this->Html->url('/jobs/jadmindetail/'.$task['Job']['id']) . '\'' , 'type' => 'button'));
                                                if($usertype == 'Admin')
                                                {
                                                    echo $form->button('<span class="bin"></span>Delete Task', array('class' => 'button button-gray', 'onclick' => ' if(confirm(\'Are you sure you want to delete this job?\')) location.href=\'' . $this->Html->url('/jobs/jdelete/'.$task['Job']['id']) . '\'' , 'type' => 'button'));
                                                } 
                                            echo '</td><td style="float:right;">'
                                                 . $form->button('<span class="icon-note"></span>Task Notes', array('class' => 'button button-gray', 'onclick' => 'location.href=\'' . $this->Html->url('/jobs/jaddnote/'.$task['Job']['id']) . '\'' , 'type' => 'button')) . '
                                                    </td>
                                        </tr> 
                                    </table>
                                </li>';
                                    }
                                elseif($fortoday > $today) {
                                    echo
                                '<li class="tick" id="' . $task['Job']['id'] . '">
                                    <table style="width:100%">
                                        <tr>
                                            <th style="width:50%; text-align:left;">
                                                <a class="calendar" href="../jobs/jadmindetail/' . $task['Job']['id'] . '">&raquo;</a>'.
                                                $this->Html->link('Upcoming Tasks', '/jobs/jadmindetail/'. $task['Job']['id']). 
                                            '</th>
                                            <th style="width:50%; float:right;">
                                                <span class="timestamp">' . $task['Job']['sdate'] . '</span>
                                            </th>
                                        </tr>
                                        <tr>
                                            <td>
                                                ' . $task['Job']['title'] . '
                                            </td>
                                            <td style="float:right;">
                                                ' . $form->button('<span class="accept"></span>Manage Task', array('class' => 'button button-gray accept', 'onclick' => 'location.href=\'' . $this->Html->url('/jobs/jadmindetail/'.$task['Job']['id']) . '\'' , 'type' => 'button'));
                                                if($usertype == 'Admin')
                                                {
                                                    echo $form->button('<span class="bin"></span>Delete Task', array('class' => 'button button-gray', 'onclick' => ' if(confirm(\'Are you sure you want to delete this job?\')) location.href=\'' . $this->Html->url('/jobs/jdelete/'.$task['Job']['id']) . '\'' , 'type' => 'button'));
                                                } 
                                            echo '</td><td style="float:right;">'
                                                        . $form->button('<span class="icon-note"></span>Task Notes', array('class' => 'button button-gray', 'onclick' => 'location.href=\'' . $this->Html->url('/jobs/jaddnote/'.$task['Job']['id']) . '\'' , 'type' => 'button')) . '
                                                    </td>
                                        </tr> 
                                    </table>
                                </li>';
                                    }
                                elseif($fortoday < $today ) {
                                    echo
                                '<li class="tick" id="' . $task['Job']['id'] . '">
                                    <table style="width:100%;">
                                        <tr>
                                            <th style="width:50%; text-align:left;">
                                                <a class="calendar" href="../jobs/jadmindetail/' . $task['Job']['id'] . '">&raquo;</a>'.
                                                $this->Html->link('Past Tasks', '/jobs/jadmindetail/'. $task['Job']['id']). 
                                            '</th>
                                            <th style="width:50%; float:right;">
                                                <span class="timestamp">' . $task['Job']['sdate'] . '</span>
                                            </th>
                                        </tr>
                                        <tr>
                                            <td>
                                                ' . $task['Job']['title'] . '
                                            </td>
                                            <td style="float:right;">
                                                ' . $form->button('<span class="accept"></span>Manage Task', array('class' => 'button button-gray accept', 'onclick' => 'location.href=\'' . $this->Html->url('/jobs/jadmindetail/'.$task['Job']['id']) . '\'' , 'type' => 'button'));
                                                if($usertype == 'Admin')
                                                {
                                                    echo $form->button('<span class="bin"></span>Delete Task', array('class' => 'button button-gray', 'onclick' => ' if(confirm(\'Are you sure you want to delete this job?\')) location.href=\'' . $this->Html->url('/jobs/jdelete/'.$task['Job']['id']) . '\'' , 'type' => 'button'));
                                                } 
                                            echo '</td><td style="float:right;">'
                                                 . $form->button('<span class="icon-note"></span>Task Notes', array('class' => 'button button-gray', 'onclick' => 'location.href=\'' . $this->Html->url('/jobs/jaddnote/'.$task['Job']['id']) . '\'' , 'type' => 'button')) . '
                                                    </td>
                                        </tr> 
                                    </table>
                                </li>';
                                    }
                                }
                                ?>

                            </ul>
                             
                        </section>
                    </div>
                    
                    
                    
